1 /*
2  * Copyright (c) 2011-2012 - Mauro Carvalho Chehab
3  * Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation version 2.1 of the License.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18  *
19  * Based on ETSI EN 300 468 V1.11.1 (2010-04)
20  *
21  */
22 
23 /**
24  * @file desc_terrestrial_delivery.h
25  * @ingroup descriptors
26  * @brief Provides the descriptors for the DVB-T terrestrial delivery system descriptor
27  * @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
28  * @author Mauro Carvalho Chehab
29  * @author Andre Roth
30  *
31  * @par Relevant specs
32  * The descriptor described herein is defined at:
33  * - ETSI EN 300 468 V1.11.1
34  *
35  * @par Bug Report
36  * Please submit bug reports and patches to linux-media@vger.kernel.org
37  */
38 
39 module libdvbv5_d.desc_terrestrial_delivery;
40 
41 import libdvbv5_d.descriptors: dvb_desc;
42 import libdvbv5_d.dvb_fe: dvb_v5_fe_parms;
43 
44 extern (C):
45 
46 /**
47  * @struct dvb_desc_terrestrial_delivery
48  * @ingroup descriptors
49  * @brief Structure containing the DVB-T terrestrial delivery system descriptor
50  *
51  * @param type			descriptor tag
52  * @param length		descriptor length
53  * @param next			pointer to struct dvb_desc
54  * @param centre_frequency	centre frequency, multiplied by 10 Hz
55  * @param bandwidth		bandwidth
56  * @param priority		priority (0 = LP, 1 = HP)
57  * @param time_slice_indicator	time slicing indicator
58  * @param mpe_fec_indicator	mpe fec indicator. If 1, MPE-FEC is not used.
59  * @param constellation		constellation
60  * @param hierarchy_information	hierarchy information
61  * @param code_rate_hp_stream	code rate hp stream
62  * @param code_rate_lp_stream	code rate lp stream
63  * @param guard_interval	guard interval
64  * @param transmission_mode	transmission mode
65  * @param other_frequency_flag	other frequency flag
66  */
67 struct dvb_desc_terrestrial_delivery
68 {
69     import std.bitmanip : bitfields;
70     align (1):
71 
72     ubyte type;
73     ubyte length;
74     dvb_desc* next;
75 
76     uint centre_frequency;
77 
78     mixin(bitfields!(
79         ubyte, "reserved_future_use1", 2,
80         ubyte, "mpe_fec_indicator", 1,
81         ubyte, "time_slice_indicator", 1,
82         ubyte, "priority", 1,
83         ubyte, "bandwidth", 3,
84         ubyte, "code_rate_hp_stream", 3,
85         ubyte, "hierarchy_information", 3,
86         ubyte, "constellation", 2,
87         ubyte, "other_frequency_flag", 1,
88         ubyte, "transmission_mode", 2,
89         ubyte, "guard_interval", 2,
90         ubyte, "code_rate_lp_stream", 3,
91         uint, "", 8));
92 
93     uint reserved_future_use2;
94 }
95 
96 // struct dvb_v5_fe_parms;
97 
98 /**
99  * @brief Initializes and parses the DVB-T terrestrial delivery system descriptor
100  *
101  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
102  * @param buf	buffer containing the descriptor's raw data
103  * @param desc	pointer to struct dvb_desc to be allocated and filled
104  *
105  * This function initializes and makes sure that all fields will follow the CPU
106  * endianness. Due to that, the content of the buffer may change.
107  *
108  * Currently, no memory is allocated internally.
109  *
110  * @return On success, it returns the size of the allocated struct.
111  *	   A negative value indicates an error.
112  */
113 int dvb_desc_terrestrial_delivery_init (
114     dvb_v5_fe_parms* parms,
115     const(ubyte)* buf,
116     dvb_desc* desc);
117 
118 /**
119  * @brief Prints the content of the DVB-T terrestrial delivery system descriptor
120  * @ingroup descriptors
121  *
122  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
123  * @param desc	pointer to struct dvb_desc
124  */
125 void dvb_desc_terrestrial_delivery_print (
126     dvb_v5_fe_parms* parms,
127     const(dvb_desc)* desc);
128 
129 /**
130  * @brief converts from internal representation into bandwidth in Hz
131  */
132 extern __gshared const(uint)[] dvbt_bw;
133 
134 /**
135  * @brief converts from the descriptor's modulation into enum fe_modulation,
136  *	  as defined by DVBv5 API.
137  */
138 extern __gshared const(uint)[] dvbt_modulation;
139 
140 /**
141  * @brief converts from the descriptor's hierarchy into enum fe_hierarchy,
142  *	  as defined by DVBv5 API.
143  */
144 extern __gshared const(uint)[] dvbt_hierarchy;
145 
146 /**
147  * @brief converts from the descriptor's FEC into enum fe_code_rate,
148  *	  as defined by DVBv5 API.
149  */
150 extern __gshared const(uint)[] dvbt_code_rate;
151 
152 /**
153  * @brief converts from internal representation into enum fe_guard_interval,
154  * as defined at DVBv5 API.
155  */
156 extern __gshared const(uint)[] dvbt_interval;
157 
158 /**
159  * @brief converts from the descriptor's transmission mode into
160  *	  enum fe_transmit_mode, as defined by DVBv5 API.
161  */
162 extern __gshared const(uint)[] dvbt_transmission_mode;